// .........................................................................
// Title: gen_duration_category.do
//
// Defines program to construct bond duration buckets
// .........................................................................

cap program drop gen_duration_category
program gen_duration_category
    gen drn_bucket = ""
    replace drn_bucket = "0-1" if ~missing(duration_y) & duration_y <= 1
    replace drn_bucket = "1-3" if ~missing(duration_y) & duration_y > 1 & duration_y <= 3
    replace drn_bucket = "3-5" if ~missing(duration_y) & duration_y > 3 & duration_y <= 5
    replace drn_bucket = "5-10" if ~missing(duration_y) & duration_y > 5 & duration_y <= 10
    replace drn_bucket = "10-15" if ~missing(duration_y) & duration_y > 10 & duration_y <= 15
    replace drn_bucket = "15-20" if ~missing(duration_y) & duration_y > 15 & duration_y <= 20
    replace drn_bucket = "20+" if ~missing(duration_y) & duration_y > 20
end
